<template>
<slot :controller="controller" :store="store" :model="model" :classNames="classNames">
  <AppExpBar :class="classNames" :id="controlID">
    <template #titleBar>
      <slot name="Caption" :controller="controller" :store="store" :model="model">
      <div class="control-header__left__caption">
        <span class="text">{{$t(model.lanResTag, model.title)}}</span>
      </div>
      </slot>
  </template>
      <template #default>
        <slot name="IBIZOrderTreeExpTree" :controller="controller" :store="store" :model="model" :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
        <IBIZOrderTreeExpTree
            :selectFirstDefault='true'
            :openView="store.openView"
            :newView="store.newView"
            name="treeexpbar_tree"
            v-bind="model.ctrlParams.IBIZOrdertreeexpbar_tree"
            :context="store.context"
            :viewParams="store.viewParams"
            :closeView="store.closeView"
            :pLoadingHelper="store.loadingHelper"
            :pViewCtx="store.viewCtx"
            @ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
            @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
            @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"/>
        </slot>
      </template>
  </AppExpBar>
</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@TREEEXPBAR}}-tree-exp-bar/{{spinalCase ctrl.codeName}}-tree-exp-bar-base.vue.hbs生成
import IBIZOrderTreeExpTree from '@widgets/ibiz-order/tree-exp-tree/tree-exp-tree.vue';
import { AppExpBar } from '@components/widgets/exp-bar';
import { useProps, useBasic, useAction, useController } from './test-cl-tree-exp-viewtreeexpbar-tree-exp-bar-hook';
import { TreeExpBarActionType, ITreeExpBarAbility, ITreeExpBarStore, IParam } from "@/core";

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { 
    model,
    controlID, 
    getClassNames, 
    useNavParamsBind, 
    useEventBind, 
    handleCtrlDestroy,
    handleCtrlInit, 
    handleCtrlAction,
    handleToolbarItemClick,
    handleQuickSearch
} = useBasic(props);

const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: TreeExpBarActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: ITreeExpBarAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
  return getClassNames(props);
});

const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: ITreeExpBarStore = controller.getStore();

onMounted(() => {
    controller.ctrlMounted();
});

onUnmounted(() => {
    controller.ctrlDestroy();
})
</script>